{literal}
	<script>
	function NextVisible()
	{
		document.test_form.submit_button.disabled = false;
	}
	</script>
{/literal}

{include file="errors.tpl"}

{if $WEB_APP.correct_answer_message neq ""}
<div class="alert alert-success">{$WEB_APP.correct_answer_message}</div>
<br>
{/if}

{if isset($WEB_APP.question)}
	<h2>{$WEB_APP.title}</h2>
	<div class="row-fluid">
	{if $WEB_APP.question->picture_url neq ""}
		{if $WEB_APP.mmtype eq "img"}
			<div><img src = "media/{$WEB_APP.media_storage}/{$WEB_APP.question->picture_url}" align=right></div>
		{else}
			<div><embed src="media/{$WEB_APP.media_storage}/{$WEB_APP.question->picture_url}" type="{$WEB_APP.mmtype}" width="145" height="45" autostart="true"  align=right></div>
		{/if}
	{/if}

	<div>{$WEB_APP.question->text_html}</div>
	</div>
	<br>
	{if $WEB_APP.hint->text neq ""}
		<div class="alert alert-info">{$WEB_APP.hint->text}</div>
		
	{/if}
	{if $WEB_APP.question->type eq 2}
		<h2>{$text.txt_one_answer}</h2>
	{else}
		<h2>{$text.txt_answers}</h2>
	{/if}

	<form  name="test_form" method = "post" action = "" onsubmit="if (this.getAttribute('submitted')) return false; this.setAttribute('submitted','true');">
        <input type="hidden" value="{$WEB_APP.question->id|escape}" name="current_question"/>
	{if $WEB_APP.question->type eq 2}
			<input name = "answer"
					type = "text"
					value = "{$WEB_APP.results}"
					id = "answer"
					class = "textf">
	{else}
		<table class="table"">
		{foreach from = $WEB_APP.answers item = answer name=loop}
		<tr>
			{if $WEB_APP.question->type eq 0}
				<td width=50>{$smarty.foreach.loop.index+1}.&nbsp;<input name = "answer" type = "radio" value = "{$answer->number}" id = "answer{$answer->number}" onclick="NextVisible()" {if $answer->number eq $WEB_APP.results}checked = "checked"{/if}></td>
			{/if}
			{if $WEB_APP.question->type eq 1}
				<td width=50>{$smarty.foreach.loop.index+1}.&nbsp;<input name = "answer[{$answer->number}]" type = "checkbox" value = "{$answer->number}" id = "answer{$answer->number}" onclick="NextVisible()" {if isset($WEB_APP.results) eq TRUE}{if is_array($WEB_APP.results) eq TRUE} {if in_array($answer->number,$WEB_APP.results, FALSE) eq TRUE}checked{/if}{/if}{/if}></td>
			{/if}
			{if $WEB_APP.question->type eq 3}
				<td width=90>{$smarty.foreach.loop.index+1}.&nbsp;
				{if $smarty.foreach.loop.index+1 <= $WEB_APP.answers_count/2}
					<select class="input-mini" name = "answer[{$answer->number}]" id = "answer{$answer->number}" onclick="NextVisible()">
					{section name = tmp start = $WEB_APP.answers_count/2+1 loop = $WEB_APP.answers_count+1}
					{assign var="answer_number" value=$answer->number}
						<option value = "{$smarty.section.tmp.index}" {if isset($WEB_APP.results)} {if $smarty.section.tmp.index eq $WEB_APP.results.$answer_number}SELECTED{/if}{/if}>{$smarty.section.tmp.index}</option>
					{/section}
					</select>
				{/if}
				</td>
			{/if}
			{if $WEB_APP.question->type eq 4}
				<td width=70>&nbsp;<select class="input-mini" name = "answer[{$answer->number}]" id = "answer{$answer->number}" onclick="NextVisible()">
				{section name = tmp start = 1 loop = $WEB_APP.answers_count+1}
				{assign var="answer_number" value=$answer->number}
					<option value = "{$smarty.section.tmp.index}"  {if isset($WEB_APP.results)} {if $smarty.section.tmp.index eq $WEB_APP.results.$answer_number}SELECTED{/if}{/if}>{$smarty.section.tmp.index}</option>
				{/section}
				</select>
				</td>
			{/if}
			<td><label style="cursor:pointer" for="answer{$answer->number}">{$answer->text_html}</label></td>
		</tr>
		{/foreach}
		</table>
	{/if}
		<div align="right">
		<input type = "submit" class = "btn-primary" value = "{$WEB_APP.submit_title}" name="submit_button" id="submit_button" {if $WEB_APP.results eq NULL && $WEB_APP.question->type neq 2}disabled{/if}>

		{if ($WEB_APP.is_back eq TRUE) and ($WEB_APP.current_question > 1)}
			<input type = "button" class = "btn" value = "{$text.txt_back}" name="back_button" onclick="return back_question()">
		{/if}
		{if $WEB_APP.settings.tst_allowstoskip eq 1}
			<input type = "button" class = "btn" value = "{$text.txt_skip}" name="skip_button" onclick="return skip_question()">
		{/if}
		</div>
	</form>
	<script>
        {if $WEB_APP.question->type eq 2}
            document.test_form.answer.focus();
        {/if}
        {literal}
        $(document).bind('keydown', 'return', function() {
		document.test_form.submit_button.click();
		});
        {/literal}
	</script>
<script>{literal}
    $(document).ready(function(){
        $("#submit_button").everyTime(5000, function(i) {
            $.post("?module=testing&action=time");
        });
    });
{/literal}</script>

	{if $WEB_APP.tst_showstats}
	<div class="row">
		<div class="span5">
		<div class="alert alert-info">
		{if isset($WEB_APP.total_questions) eq TRUE}
			<p>{$text.txt_total_questions}: <strong>{$WEB_APP.total_questions}</strong></p>
		{/if}
		{if $WEB_APP.stat_current eq TRUE}
			<p>{$text.txt_current_question}: <strong>{$WEB_APP.current_question}</strong></p>
		{/if}
		{if isset($WEB_APP.correct_answers)}
			<p>{$text.txt_correct_answers}: <strong>{$WEB_APP.correct_answers}</strong></p>
		{/if}
		{if $WEB_APP.tst_showpercent}
			<p>{$text.txt_percentage_of_correct_answers}: <strong>{$WEB_APP.percent_right}%</strong></p>
		{/if}
		{if $WEB_APP.show_time_left eq TRUE}
			<p>{$text.txt_time_left}: <strong>{$WEB_APP.time_left}</strong></p>
		{/if}
		</div>
		</div>
	</div>
	{/if}
{/if}
